{extend name="base" /}
{block name="content"}
<script language="javascript" type="text/javascript" src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>
{include file="public:editor"/}
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>cms</span>
            <span class="icon-angle-right"></span>
            <span>管理信息</span>
            <span class="icon-angle-right"></span>
            <span>{$column_name}</span>
            <span class="icon-angle-right"></span>
            <span>{$info ? '编辑' : '添加'}信息</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-tab-tit clearfix">
                <ul>
                    <li class="item-act"><a href="javascript:;">基本属性</a></li>
                    <li hidden><a href="javascript:;">选项设置</a></li>
                </ul>
            </div>
            <div class="m-form mt-10">
                <form class="layui-form" id="j_form">
                    <div class="m-tab-con">
                        <table class="m-table">
                            <thead>
                                <tr>
                                    <th colspan="2">基本属性</th>
                                </tr>
                            </thead>
                            <tbody>
                                {foreach name="html" item="v"}
                                {if condition="$v['type'] eq 'editor'"}
                                <tr>
                                    <td colspan="2">{:html_entity_decode($v.label)}</td>
                                </tr>
                                <tr>
                                    <td colspan="2">{:html_entity_decode($v.value)}</td>
                                </tr>
                                <script>
                                    // KindEditor.ready(function(K) {
                                    //     var editor = K.create('textarea[name="{$v.name}"]', {
                                    // 		allowFileManager: true,
                                    //         uploadJson: uploadJson,
                                    //         fileManagerJson: fileManagerJson,
                                    //         afterBlur: function () {
                                    //             this.sync();
                                    //         }
                                    // 	});
                                    // });
                                    UE.getEditor('{$v.name}');
                                </script>
                                {else/}
                                <tr>
                                    <td width="15%">{:html_entity_decode($v.label)}</td>
                                    <td>{:html_entity_decode($v.value)}</td>
                                </tr>
                                {/if}
                                {/foreach}


                            </tbody>
                        </table>
                    </div>
                    <div class="m-tab-con dn" style="display: none;">
                        <table class="m-table">
                            <thead>
                                <tr>
                                    <th colspan="2">选项设置</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td width="15%"><label for="">访问权限</label></td>
                                    <td><div class="lay-checked">{foreach name="roles" item="role"}<input type="checkbox" name="access_role_ids[]" value="{$role.id}" title="{$role.name}" lay-skin="primary"{if condition="strpos(','.$info['access_role_ids'].',', ','.$role['id'].',') !== false"} checked{/if} />{/foreach}</div></td>
                                </tr>
                                <tr>
                                    <td><label for="">审核通过</label></td>
                                    <td><div class="lay-checked"><input type="checkbox" name="checked" value="1" title="通过" lay-skin="primary" {if condition="!$info || $info['checked'] eq 1"} checked{/if}/></div></td>
                                </tr>
                                <tr>
                                    <td><label for="">推荐级别</label></td>
                                    <td>
                                        <div class="lay-select">
                                            <select name="isgood">
                                                {foreach name="$attr['isgood']" key="key" item="val"}
                                                <option value="{$key}"{if condition="$info['isgood'] eq $key"} selected{/if}>{$val}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td><label for="keywords">关键词</label></td>
                                    <td><input type="text" class="u-ipt u-ipt-long" name="keywords" id="keywords" placeholder="请输入关键词" value="{$info.keywords ?: ''}" /></td>
                                </tr>
                                <tr>
                                    <td><label for="external_link">外部链接</label></td>
                                    <td><input type="text" class="u-ipt u-ipt-long" name="external_link" id="external_link" placeholder="请输入外部链接" value="{$info.external_link ?: ''}" /></td>
                                </tr>
                                <tr>
                                    <td><label for="diy_browse_nums">自定义浏览量</label></td>
                                    <td><input type="text" class="u-ipt u-ipt-small" name="diy_browse_nums" id="diy_browse_nums" value="{$info.diy_browse_nums ?: 0}" /></td>
                                </tr>
                                <tr>
                                    <td><label for="actual_browse_nums">实际浏览量</label></td>
                                    <td><input type="text" class="u-ipt u-ipt-small" name="actual_browse_nums" id="actual_browse_nums" value="{$info.actual_browse_nums ?: 0}" readonly /><span>实际浏览量不可修改，只可查看。</span></td>
                                </tr>
                                <tr>
                                    <td><label for="list_order">排序</label></td>
                                    <td><input type="text" class="u-ipt u-ipt-tiny" name="list_order" id="list_order" value="{$info.list_order ?: 0}" /><span>值越大越排在前面</span></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="m-form-btn"><input type="hidden" name="id" value="{$info.id}"><button id="j_btn" class="u-btn">确定提交</button></div>
                    <input type="hidden" name="column_id" value="{$column_id}" />
                    <input type="hidden" name="ismember" value="0" />
                </form>
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="redirect_uri" value="{:url('contents/index', ['column_id' => $column_id])}" />
{/block}
{block name="extrajs"}
{include file="public:upload"/}
<script>
    layui.use(['layer', 'form'], function(){
        var layer  = layui.layer,
                form   = layui.form;
        var province_id ="{$info.province}";
        var city ="{$info.city}";
        var district ="{$info.district}";
        //城市三级联动
        var p_options="";
        var c_options="";
        var a_options="";
        $.getJSON("/static/data/address.json", "", function(data) {
            //each循环 使用$.each方法遍历返回的数据date
            $.each(data, function(i, item) {
                // console.log(item)
                p_options+="<option value='"+item.region_id+"'>"+item.region_name+"</option>";
                if(item.region_id==province_id){
                    $.each(item.child, function(i, citem) {
                        c_options+="<option value='"+citem.region_id+"'>"+citem.region_name+"</option>";
                        if(citem.region_id==city){
                            $.each(citem.child, function(i, aitem) {
                                a_options+="<option value='"+aitem.region_id+"'>"+aitem.region_name+"</option>";
                            });
                        }
                    });
                }
            });

            //省
            $("select[name='province']").html(p_options);
            $("select[name='province'] option").attr("selected",false);
            $("select option[value='"+province_id+"']").attr("selected",true);

            $("select[name='city']").html(c_options);
            $("select[name='city'] option").attr("selected",false);
            $("select option[value='"+city+"']").attr("selected",true);

            $("select[name='district']").html(a_options);
            $("select[name='district'] option").attr("selected",false);
            $("select option[value='"+district+"']").attr("selected",true);

            form.render('select');
        });
    });
</script>
{/block}